﻿using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using DeSleeper.Client.Framework;
using DeSleeper.Client.Installation;

namespace DeSleeper.Client.Service
{
	/// <summary>
    /// Interaction logic for ServiceView.xaml
	/// </summary>
	public partial class ServiceView : PageViewBase<ServiceViewModel>
	{
		public bool IsInstalled
		{
			get { return (bool)GetValue(IsInstalledProperty); }
			set { SetValue(IsInstalledProperty, value); }
		}

		// Using a DependencyProperty as the backing store for IsInstalled.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty IsInstalledProperty =
			DependencyProperty.Register("IsInstalled", typeof(bool), typeof(ServiceView), new UIPropertyMetadata(false));

		public ServiceView()
		{
			InitializeComponent();
			setInstalled();
		}

		void executionComplete(object sender, RunWorkerCompletedEventArgs e)
		{
			setInstalled();
		}

		private void setInstalled()
		{
		    IsInstalled = Installer.IsInstalled();
			
			installServiceButton.Content = IsInstalled ? "Reinstall" : "Install";
		}
	}
}
